<html>
<?php
    session_start();
    include('class.php');
    $db = new DB();
    $result = $db->getData();
?>

	<head>
		<link rel="stylesheet" href="bootstrap-theme.css">
		<link rel="stylesheet" href="bootstrap-theme.min.css">
		<link rel="stylesheet" href="bootstrap.min.css">
		<link rel="stylesheet" href="bootstrap.css">
		<link rel="stylesheet" href="DIY.css">
	</head>

	<body>
		<div class="container">
			<ul class="nav nav-tabs">
				<li role="presentation" class="active"><a href="Namelist.php" >Staff Information</a></li>
				<li role="presentation"><a href="CheckAttendanceForManager.php">Check Attendance</a></li>
				<li role="presentation"><a href="AttendanceStatistics.php">Attendance Statistics</a></li>
				<li role="presentation"><a href="DailyAssignment.php">Daily Assignment</a></li>
				<li role="presentation"><a href="BulletinForManager.php">Bulletin</a></li>
				<li role="presentation"><a href="User2.php">Self Information</a></li>
				<a class="logout" href="Logout.php">Log out</a>
				<label class="logout">Company Name</label>

			</ul>

			<form method="post" action="staffInfoForManager2.php">
				<div class="row lengthrow">
					<div class="col-lg-6">
						<div class="input-group">
							<span class="input-group-btn">
        						<button class="btn btn-default">Search</button>
      						</span>
							<input type="text" class="form-control" placeholder="Input Id" name="staffId">
						</div>
						<!-- /input-group -->
					</div>
				</div>
			</form>
			<div class="panel panel-default">

			</div>

			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">Name List</h3>
				</div>
				<div class="panel-body">
					<table class="table table-striped">
						<tr>
							<th width="50%">id</th>
							<th width="50%">Staff_name</th>
						</tr>
						<tbody class="table table-hover">


							<?php
        					while($row = mysql_fetch_array($result)){
    						?>
								<tr>
									<td>
										<p>
											<?php echo $row['id']?>
										</p>
									</td>
									<td>
										<span><?php echo $row['name']?></span>
									</td>
                                    

								</tr>
							<?php } ?>

						</tbody>
					</table>
				</div>

			</div>

		</div>
		<script src="homepage_js/jquery.min.js"></script>
		<script src="homepage_js/bootstrap.min.js"></script>
		<script type="text/javascript">
			$('.table-hover tr').find("td:eq(1)").each(
				function() {
					$('.table-hover tr').find("td:eq(1)").click(
						function() {
							var name = $(this).find('span').text();
							var id = Number($(this).parent().children(0).find('p').text());
							var data = new Array(2);
							data[0] = id;
							data[1] = name;
							// $_SESSION['deleteid']=data[0];
							data = JSON.stringify(data);
							console.log(data);
							var f = formFormat();
							formElements(f, "data", data)
							f.action = "StaffInfoForManager.php"
							f.submit();
						});
				}
			);

			function formFormat() {
				var f = document.createElement("form");
				document.body.appendChild(f);
				f.method = "post";
				return f;
			}

			function formElements(eForm, eName, eValue) {
				var e = document.createElement("input");
				eForm.appendChild(e);
				e.name = eName;
				if (!document.all) {
					e.style.display = 'none';
				}
				e.value = eValue;
				return e;
			}

		</script>

	</body>

</html>
